package T1;

import java.lang.ref.SoftReference;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;

/**
 * @Author admin
 * @Date 2019/4/9 13:39
 */
public class Test {
    public static void main(String[] args) {
        System.out.println("请输入一句话：");
        Scanner sc=new Scanner(System.in);
        String s1=sc.nextLine();
        String[] s=s1.split(" ");

        HashMap<String,Integer> hashMap=new HashMap<String, Integer>();
        for (int i = 0; i <s.length ; i++) {
            if (hashMap.containsKey(s[i])){
                Integer value= hashMap.get(s[i]);
                value++;
                hashMap.put(s[i],value);
            }else {
                hashMap.put(s[i],1);
            }
        }
         Set<String> keyset=hashMap.keySet();
        Iterator iterator=keyset.iterator();
        while (iterator.hasNext()){
            String key=(String)iterator.next();
            Integer value=hashMap.get(key);
            System.out.println(key+":"+value);
        }

    }
}
